package org.gradle;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public class WebSocketEncoders implements Encoder.Text<Message>{

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public String encode(Message object) throws EncodeException {
        return JSON.toJSONString(object);
    }

    @Override
    public void init(EndpointConfig config) {
        logger.info("MessageEncoder - init method called");
    }

    @Override
    public void destroy() {
        logger.info("MessageEncoder - destroy method called");
    }
}
